// src/shoops/shoop.service.ts
import { Injectable } from '@nestjs/common';

export interface Shoop {
  id: number;
  name: string;
  price: number;
  stock: number;
}

@Injectable()
export class ShoopService {
  // 模拟商品数据数组
  private readonly shoops: Shoop[] = [
    { id: 1, name: "无线鼠标", price: 99, stock: 100 },
    { id: 2, name: "机械键盘", price: 299, stock: 50 },
    { id: 3, name: "蓝牙耳机", price: 199, stock: 75 }
  ];

  /**
   * 获取所有商品
   */
  getAllShoops(): Shoop[] {
    return this.shoops;
  }

  /**
   * 根据ID获取商品
   * @param id 商品ID
   */
  getShoopById(id: number): Shoop | null {
    return this.shoops.find(shoop => shoop.id === id) || null;
  }
}